#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

// 计算最大公约数
int gcd(int a, int b) {
    while (b != 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

// 分解质因数并更新质因数表
void factorize(int d, unordered_map<int, int>& x_factors) {
    if (d == 1) return;
    
    // 处理因子2
    int count = 0;
    while (d % 2 == 0) {
        d /= 2;
        count++;
    }
    if (count > 0) {
        x_factors[2] = max(x_factors[2], count);
    }
    
    // 处理奇因子
    for (int i = 3; i * i <= d; i += 2) {
        count = 0;
        while (d % i == 0) {
            d /= i;
            count++;
        }
        if (count > 0) {
            x_factors[i] = max(x_factors[i], count);
        }
    }
    
    // 处理剩余的质因数
    if (d > 1) {
        x_factors[d] = max(x_factors[d], 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        
        vector<int> b(n);
        for (int i = 0; i < n; ++i) {
            cin >> b[i];
        }
        
        unordered_map<int, int> x_factors;
        
        for (int i = 0; i < n - 1; ++i) {
            int bi = b[i];
            int bj = b[i + 1];
            int g = gcd(bi, bj);
            
            if (bi % bj == 0 || bj % bi == 0) {
                continue;
            }
            
            int d = bj / g;
            if (d == 0) continue;
            
            factorize(d, x_factors);
        }
        
        long long x = 1;
        for (const auto& pair : x_factors) {
            for (int i = 0; i < pair.second; ++i) {
                x *= pair.first;
            }
        }
        
        cout << (x == 0 ? 1 : x) << endl;
    }
    
    return 0;
}